﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

[assembly: TagPrefix("Jalal.Library.Web.Control", "ucc")]
namespace Jalal.Library.Web.Control
{
    [SupportsEventValidation, ValidationProperty("ImageUrl")]
    [ToolboxData("<{0}:SortButton runat=server></{0}:SortButton>")]
    public class SortButton : ImageButton
    {
        private bool isSortUpButton;
        public bool IsSortUpButton
        {
            get { return isSortUpButton; }
            set { isSortUpButton = value; }
        }

        private string sortUpImageUrl;
        public string SortUpImageUrl
        {
            get { return sortUpImageUrl; }
            set { sortUpImageUrl = value; }
        }

        private string sortDownImageUrl;
        public string SortDownImageUrl
        {
            get { return sortDownImageUrl; }
            set { sortDownImageUrl = value; }
        }

        protected override void OnLoad(EventArgs e)
        {
            if (isSortUpButton)
            {
                if (string.IsNullOrEmpty(sortUpImageUrl))
                    this.ImageUrl = "~/App_Themes/" + Page.Theme + "/image/sort-up.jpg";
                else
                    this.ImageUrl = "~/App_Themes/" + Page.Theme + sortUpImageUrl;
            }
            else
            {
                if (string.IsNullOrEmpty(sortDownImageUrl))
                    this.ImageUrl = "~/App_Themes/" + Page.Theme + "/image/sort-down.jpg";
                else
                    this.ImageUrl = "~/App_Themes/" + Page.Theme + sortDownImageUrl;
            }
            base.OnLoad(e);
        }
    }
}
